<?php

namespace App\Transformers;

use App\Models\UniDeliverProductNotification;
use Carbon\Carbon;
use League\Fractal\TransformerAbstract;

class UniDeliverProductNotificationTransformer extends TransformerAbstract
{
    public function transform(UniDeliverProductNotification $uniDeliverProductNotification)
    {
        return [
            'id'           => $uniDeliverProductNotification->id,
            'order_id'     => $uniDeliverProductNotification->order_id,
            'order_no'     => $uniDeliverProductNotification->order_no,
            'machine_id'   => $uniDeliverProductNotification->machine_id,
            'aisle_number' => $uniDeliverProductNotification->aisle_number,
            'number'       => $uniDeliverProductNotification->number,
            'extra'        => $uniDeliverProductNotification->extra,
            'result'       => $uniDeliverProductNotification->result,
            'created_at'   => (string) $uniDeliverProductNotification->created_at,
            'updated_at'   => (string) $uniDeliverProductNotification->updated_at,
            'diffInSecond' => Carbon::now()->diffInSeconds(Carbon::parse($uniDeliverProductNotification->updated_at), true)
        ];
    }
}
